package com.cnswhy.cloud.server.common.entity.enumeration;

import com.cnswhy.cloud.common.core.base.BaseEnum;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.Getter;

import java.util.stream.Stream;

/**
 * <p>
 * 实体注释中生成的类型枚举
 * 
 * </p>
 *
 * @author cnswhy
 * @date 2020-10-14
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "TransType", description = "钱包类型 #TransType{WITHDRAW:提现;CHARGE:充值;-枚举")
public enum TransType implements BaseEnum {

    /**
     * WITHDRAW="提现"
     */
    WITHDRAW("提现"),
    /**
     * CHARGE="充值"
     */
    CHARGE("充值"),
    /**
     * SHARE_CHARGE="分享充值"
     */
    /*SHARE_CHARGE("分享充值"),
    SHARE_TRANSFER("分享转账"),
    COUPON_CHARGE("拼购券充值"),
    COUPON_TRANSFER("拼购券转账"),
    SPELL_BALANCE_CHARGE("拼团收益"),
    SPELL_VALUE_CHARGE("拼团值收益"),
    SPELL_BALANCE_TRANSFER("拼团收益转账"),
    CONTRIBUTION_BALANCE_CHARGE("贡献收益充值"),
    CONTRIBUTION_BALANCE_TRANSFER("贡献收益转账"),
    TEAM_BALANCE_CHARGE("队长分红"),
    CONSUME_BALANCE_CHARGE("消费分红"),
    TEAM_BALANCE_TRANSFER("队长分红转账"),
    CONTRIBUTION("贡献收益"),
    LOVE_BALANCE_TRANSFER("爱心收益转账"),
    LOVE_BALANCE_CHARGE("爱心收益充值"),
    LOVE_BALANCE_RECYCLE("爱心收益回收"),
    BACK_ORDER_CHARGE("平台回购充值"),
    SPELL_ORDER("拼团"),
    SHOP_ORDER("商城购买"),
    SPELL_ORDER_FAILURE("拼团失败"),
    SPLIT("拼团分账"),
    SMALL_SPLIT("小队奖励"),
    CONSUME_SPLIT("消费分账"),
    SPLIT_TRANSFER("分润转出"),
    AGENT_SPLIT_TRANSFER("推广红包转出"),
    BUY_BACK_CHARGE("回购充值"),
    RECYCLE("回收"),*/
    NO_CARD_SPLIT("无卡分账"),
    IOTCL_SPLIT("充电线分账"),
    REGISTER_REWORD("激活奖励"),
    FIRST_NO_CARD_PAY("首笔交易奖励"),
    INNER_TRANSFER("内转"),
    NO_CARD_TRANSFER("快捷收益转出"),
    REWORD_TRANSFER("奖励收益转出"),
    IOTCL_TRANSFER("充电线收益转出"),
    ;

    @ApiModelProperty(value = "描述")
    private String desc;


    /**
     * 跟就当前枚举的name匹配
     */
    public static TransType match(String val, TransType def) {
        return Stream.of(values()).parallel().filter((item) -> item.name().equalsIgnoreCase(val)).findAny().orElse(def);
    }

    public static TransType get(String val) {
        return match(val, null);
    }

    public boolean eq(TransType val) {
        return val == null ? false : eq(val.name());
    }

    @Override
    @ApiModelProperty(value = "编码", allowableValues = "WITHDRAW,CHARGE,SHARE_CHARGE,SHARE_TRANSFER", example = "WITHDRAW")
    public String getCode() {
        return this.name();
    }

}
